package com.game.server.message.proto.execute;

import com.comm.ISession;
import com.game.majiang.config.LogManager;
import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.majiang.logic.chexuan.ChexuanTabale;
import com.game.server.message.proto.in.AbstractBankerGameStartReq;
import com.game.server.message.proto.out.BankerGameStartRsp;
import com.game.server.system.AbstractTable;

public class BankerGameStartReq extends AbstractBankerGameStartReq {

    @Override
    public void Execute(ISession session) {
		LogManager.getInstance().Log("游戏开始");
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());
        if (client != null&&client.checkClick(msgcode)) {
        	BankerGameStartRsp rsp = new BankerGameStartRsp();
        	rsp.setIsok(1);
        	AbstractTable abTable = client.getTable();
        	if (abTable != null) {
				ChexuanTabale table = (ChexuanTabale) abTable;
				if(table.getCreate().getBankerid() == client.getUserId()) {
					table.bankerGameStart();
					rsp.setIsok(0);
				}
			} 
        	if(rsp.getIsok().intValue() == 0) {
        		abTable.BroadCast(rsp, 2);
        	} else {
        		client.Send(rsp);
        	}
        	
        }
    }

}
